package com.example.yc23.demo.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.yc23.demo.pojo.Review;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface ReviewMapper extends BaseMapper<Review>{
    List<Review> selectReviewList(@Param("state") Integer state);
    //查询某个用户是否给评论地点赞
    @Select("select count(*) from thumbsup where review_id = #{param1}")
    int selectthumbsupById(Integer reviewId);

    @Select("select count(*) from thumbsup where user_id = #{param1} and review_id = #{param2}")
    int selectthumbsup(Integer userId,Integer reviewId);
    @Insert("insert into thumbsup value(#{param1},#{param2})")
    int insertthumbsup(Integer userId,Integer reviewId);
    @Delete("delete from thumbsup where user_id = #{param1} and review_id = #{param2}")
    int deletethumbsup(Integer userId,Integer reviewId);

}
